using System;
using System.IO;

namespace Atomic.Vasp.Options
{
	/// <summary>
	/// Static ionic calculation. No update of ions (IBRION=-1). This is actually the default VASP behavior unless NSW is specified.
	/// http://cms.mpi.univie.ac.at/vasp/guide/node110.html
	/// </summary>
	[Serializable]
	public class StaticIonicCalculation : VaspOption
	{
		public StaticIonicCalculation()
			: this(null)
		{
		}

		public StaticIonicCalculation(int? outerLoopSteps)
		{
			if (outerLoopSteps.HasValue && outerLoopSteps.Value < 0)
			{
				throw new ArgumentException();
			}

			OuterLoopSteps = outerLoopSteps;
		}

		public override void Write(VaspIncar incar, DirectoryInfo directory)
		{
			incar.Add("IBRION", "-1", "No update of ions");

			if (OuterLoopSteps.HasValue)
			{
				incar.Add("NSW", OuterLoopSteps.Value.ToString(), "Outer loop steps");
			}
		}

		public int? OuterLoopSteps
		{
			get;
			private set;
		}
	}
}
